{%extends '../base/base.tpl'%}

{%block 'title'%}运营管理-订单管理{%/block%}

{%block 'header_css'%}
<link href="../../static/js/common/plugins/chosen/chosen.css?__inline" rel="stylesheet">
<link href="../../static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<link href="../../static/css/plugins/cropper/cropper.min.css" rel="stylesheet">  <!--图片上传加裁剪-->


<!-- 上传组件 -->
<link href="../../static/js/common/plugins/fileinput/fileinput.min.css" rel="stylesheet"/>
<!--富文本 -->
<link href="../../static/js/common/plugins/kindeditor/themes/qq/qq.css" rel="stylesheet"/>
<link href="../../static/css/animate.min.css" rel="stylesheet">
<link href="../../static/css/style.min.css?__inline" rel="stylesheet">
<link href="../../static/css/common.css?__inline" rel="stylesheet">


<style type="text/css">
    table{font-size:13px;text-align:center;}
    thead{font-weight:bold;text-align:center;}
    th{text-align: center;}
    .list_edit_table{}
    .is_must{line-height: 34px;}
    table a{display: inline-block;}
    .img-preview-sm{height:78px;}
    .note-editor .note-editable{background: #fff}
    .note-editable{min-height: 200px;}
    .tangram-suggestion-main{z-index: 10000}
    .BMapLabel{margin-top: -20px;max-width: inherit;}
    .btn-danger{    
        background-color: #ec4758;
        border-color: #ec4758;
        color: #FFF;
    }
    .btn-success{
        background-color: #1a7bb9;
        border-color: #1a7bb9;
        color: #FFF;
    }
    .list_verify{width:100%;overflow: hidden;}
    .list_verify_sn{font-size:24px;letter-spacing: 3px;}
    .varify_detail{width:70%;margin:0 auto;overflow: hidden; display: none;}
    .varify_detail .form-group{overflow: hidden;}
</style>
{%/block%}

{%block 'header_js'%} 

{%/block%}

{%block 'foot'%}

{%/block%}

{%block 'body'%}

<div id="wrapper">
    {%include file="../../widget/left_menu.tpl"%}
    <div id="page-wrapper" class="gray-bg dashbard-1">
        {%include file="../../widget/header.tpl"%}
        <div class="row J_mainContent" id="content-main">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h3>核销管理</h3>
                </div>
                <div class="ibox-content">
                    <div class="list_verify">
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><h2 style="line-height:36px;" class=" pull-right">请输入验证码</h2></label>
                            <div class="col-sm-6">
                                <input type="number" placeholder="请输入验证码" name="verify_sn" class="form-control list_verify_sn input-lg m-b">
                                <input type="hidden" placeholder="请输入验证码" name="verify_sn" class="form-control hide_verify_sn input-lg m-b">
                            </div>
                            <button type="button" class="col-sm-1 btn btn-primary list_search_verify btn-lg">查询</button>
                        </div>
                        
                    </div>
                    <div class="varify_detail well">
                        
                    </div>
                </div>
            </div>
        </div>
        {%include file="../../widget/footer.tpl"%}
    </div>
</div>
{%include file="../../widget/editable_mod.tpl"%}
{%/block%}
  
{%block 'foot_js'%}
<script src="../../static/js/common/plugins/chosen/chosen.jquery.js?__inline"></script>
<script src="../../static/js/common/content.min.js"></script>
<script src="../../static/js/common/plugins/validate/jquery.validate.min.js"></script>
<script src="../../static/js/common/plugins/validate/messages_zh.min.js"></script>
<script src="../../static/js/common/jquery.form.js"></script>
<script src="../../static/js/common/plugins/layer/laydate/laydate.js"></script> 
<script src="../../static/js/common/plugins/sweetalert/sweetalert.min.js"></script>
<script src="../../static/js/common/plugins/jeditable/jquery.jeditable.js"></script> 
<script src="../../static/js/common/plugins/dataTables/jquery.dataTables.js"></script> 
<script src="../../static/js/common/plugins/dataTables/dataTables.bootstrap.js"></script> 
<script src="../../static/js/common/plugins/cropper/cropper.min.js"></script> 
<script src="../../static/js/common/plugins/ajaxfileupload/ajaxfileupload.js"></script> 

<!-- 上传组件 -->
<script src="../../static/js/common/plugins/fileinput/fileinput.min.js"></script>
<script src="../../static/js/common/plugins/fileinput/fileinput_locale_zh.js"></script>
<!-- 富文本 -->
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="../../static/js/common/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<!-- <script src="../../static/js/table/tableoperation.js"></script> -->
<!-- <script src="../../static/js/table/tableModel.js"></script> -->
<script type="text/javascript">


$(function(){
    $(".list_search_verify").click(function(){
        $(".hide_verify_sn").val($(".list_verify_sn").val());
        if($(".list_verify_sn").val() != "" && $(".list_verify_sn").val() != null){
            $.ajax({
                url:"/ajax/call/verify/view",
                data:{
                    "verify_sn":$(".list_verify_sn").val()
                },
                type:"post",
                success:function(data){
                    if(data.errno == undefined || data.errno == 0){
                        var html = '';
                            html += '<div class="form-group"><label class="col-sm-2 control-label">商家名称：</label><div class="col-sm-10">'+data.vender_name+'</div></div>';
                            html += '<div class="form-group"><label class="col-sm-2 control-label">商品名称：</label><div class="col-sm-10">'+data.goods_name+'</div></div>';
                            html += '<div class="form-group"><label class="col-sm-2 control-label">商品金额：</label><div class="col-sm-10">'+data.goods_price+'</div></div>';
                            html += '<div class="form-group"><label class="col-sm-2 control-label">用户手机号：</label><div class="col-sm-10">'+data.phone+'</div></div>';
                            html += '<div class="form-group"><label class="col-sm-2 control-label">订单时间：</label><div class="col-sm-10">'+data.order_time+'</div></div>';

                            if(data.is_use != undefined){
                                if(data.is_use == "1"){
                                    html += '<div class="form-group"><label class="col-sm-2 control-label ">使用状态：</label><div class="col-sm-10" style="color:#1ab394">已使用</div></div>';
                                    html += '<div class="form-group"><label class="col-sm-2 control-label">使用时间：</label><div class="col-sm-10">'+data.use_time+'</div></div>';
                                }else{
                                    html += '<div class="form-group"><label class="col-sm-2 control-label">使用状态：</label><div class="col-sm-10 item_is_use" style="color:#E88080">未使用</div></div>';
                                    html += '<div class="text-center"><button type="button" class=" btn btn-primary data_use_btn" onclick="iSuseVerify()">确认使用</button></div>';
                                }
                            }else if(data.left_count){
                                if(data.left_count > "0"){
                                    html += '<div class="form-group"><label class="col-sm-2 control-label">剩余次数：</label><div class="col-sm-10 item_is_use">'+data.left_count+'</div></div>';
                                    html += '<div class="text-center"><button type="button" class=" btn btn-primary data_use_btn" onclick="iSuseVerify()">确认使用</button></div>';
                                }else{
                                    html += '<div class="form-group"><label class="col-sm-2 control-label">剩余次数：</label><div class="col-sm-10">'+data.left_count+'</div></div>';
                                }
                                

                            }
                        $(".varify_detail").show().html("").append(html);
                    }else{
                        if(typeof data == "string" ){
                            if(data.indexOf("nopermission_yes") >= 0){
                                swal("系统提示", "您没有权限操作！", "error");
                                return;
                            }
                        }
                        $(".varify_detail").hide().html("");
                        swal("系统提示", data.errmsg, "error");
                    }
                }   
            })
        }else{
            $(".varify_detail").hide().html("");
            swal("系统提示", "请输入验证码", "error");
        }
    });
});
function iSuseVerify(){
    swal({
        title: "确定要核销此验证码？",
        text: "核销后将无法恢复，请谨慎操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        closeOnConfirm: false
        }, function () {
        useVerify();
    });
}
function useVerify(){
    $.ajax({
        url:"/ajax/call/verify/use",
        data:{
            "verify_sn":$(".hide_verify_sn").val()
        },
        type:"post",
        success:function(data){
            if(data.errno == undefined || data.errno == 0){
                if(data.is_use){
                    if(data.is_use == 1){
                        $(".item_is_use").html("使用成功").css("color","#1ab394");
                        var html = '<div class="form-group"><label class="col-sm-2 control-label">使用时间：</label><div class="col-sm-10">'+data.use_time+'</div></div>';
                        $(".text-center").before(html);
                        $(".data_use_btn").remove();
                        swal("核销成功！", "您已经核销成功。", "success");
                    }else{
                        swal("系统提示", "出错了", "error");
                    }
                }else if(data.left_count){
                    if(data.left_count > 0){
                        $(".item_is_use").html(data.left_count).css("color","#1ab394");
                        $(".data_use_btn").remove();
                        swal("核销成功！", "您已经核销成功。", "success");
                    }else{

                    }

                }
            }else{
                if(typeof data == "string" ){
                    if(data.indexOf("nopermission_yes") >= 0){
                        swal("系统提示", "您没有权限操作！", "error");
                        return;
                    }
                }
                swal("系统提示", data.errmsg, "error");
            }
        }   
    })
}
  

 

</script> 
{%/block%}

